﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using HMS_Hospital_Team2._6.DA;
using HMS_Hospital_Team2._6.BL;
using HMS_Hospital_Team2._6.DO;
using HMS_Hospital_Team2._6.GUI;
using System.Windows.Forms;

namespace HMS_Hospital_Team2._6.GUI
{
    public partial class frmSelectPostion : Form
    {
        //HMSHospitalEntities context = new HMSHospitalEntities();
        NhanVienBL Nhanvien = new NhanVienBL();
        PhongBanBL PhongBan = new PhongBanBL();
        string stendn = "";
        string smk = "";
        public frmSelectPostion(string s1,string s2)
        {
            stendn = s1;
            smk = s2;
            InitializeComponent();
            List<phanquyen> thongtintk = BL.NhanVienBL.Loadthongtindangnhap(stendn, smk);
            if (thongtintk[0].MaQuyen.Equals(1))
            {
                cmbChonVaiTro_ChonVT.Enabled = false;
                cmbChonVaiTro_ChonVT.SelectedItem = 1;
            }
            else
            {
                if (thongtintk[0].MaQuyen.Equals(2))
                {
                    cmbChonVaiTro_ChonVT.Enabled = false;
                    cmbChonVaiTro_ChonVT.SelectedItem = 2;
                }
            }
        }


        private void btnHoanTatViTri_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void frmSelectPostion_Load(object sender, EventArgs e)
        {
            //Load data lên combobox vai trò.
            cmbChonVaiTro_ChonVT.DataSource = Nhanvien.LoadChucVuBL();
            cmbChonVaiTro_ChonVT.DisplayMember = "TenChucVu";
            cmbChonVaiTro_ChonVT.ValueMember = "MaChucVu";

            //Load data lên combobox Chọn Đơn vị
            cmbDonVi_ChonVT.DataSource = PhongBan.LoadDuLieuBL();
            cmbDonVi_ChonVT.DisplayMember = "TenPhongBan";
            cmbDonVi_ChonVT.ValueMember = "MaPhongBan";
        }

        private void cmbDonVi_ChonVT_SelectedValueChanged(object sender, EventArgs e)
        {
            string sMaPB = cmbDonVi_ChonVT.SelectedValue.ToString();
            cmbChonBan_ChonVT.DataSource = PhongBan.LoadDuLieu_Banthu(sMaPB);
            cmbChonBan_ChonVT.DisplayMember = "TenBan";
            cmbChonBan_ChonVT.ValueMember = "MaBan";
        }
    }
}
